package drds.data_propagate.store;

import com.google.common.collect.MapMaker;
import drds.data_propagate.common.AbstractLifeCycle;
import org.springframework.util.Assert;

import java.util.Map;

/**
 * @author zebin.xuzb 2012-10-30 下午3:45:17
 * @since 1.0.0
 */
public abstract class AbstractGroupStore<T> extends AbstractLifeCycle implements GroupEventStore<T> {

    protected Map<String, StoreInfo> stores = new MapMaker().makeMap();

    @Override
    public void addStoreInfo(StoreInfo storeInfo) {
        checkInfo(storeInfo);
        stores.put(storeInfo.getStoreName(), storeInfo);
    }

    protected void checkInfo(StoreInfo info) {
        Assert.notNull(info);
        Assert.hasText(info.getStoreName());
    }

}
